上一篇介紹了IQKeyboardManager。現在這篇來介紹IQKeyboard的功能。
IQKeyboardManager.shared.enableAutoToolbar = false
這個指令能隱藏或顯示Toolbar, 更改布林值可以顯示或隱藏
IQKeyboardManager.shared.overrideKeyboardAppearance = true
IQKeyboardManager.shared.keyboardAppearance = .alert
keyboardApperaance 有四個值可以設,分別是dark, default, light, alert
IQKeyboardManager.shared.keyboardDistanceFromTextField = 200
IQKeyboardManager.shared.toolbarTintColor = .blue //字體顏色
IQKeyboardManager.shared.toolbarDoneBarButtonItemText = "aaaa" //Done按鈕所顯示的文字
IQKeyboardManager.shared.toolbarBarTintColor = .red //Toolbar的顏色
IQKeyboardManager.shared.shouldResignOnTouchOutside = true
原本的鍵盤當點擊鍵外時不會收起鍵盤,下了這條指令後就會收起鍵盤了。